﻿package plugin.instances.game
{
    import com.core.*;
    import com.sh.game.util.*;
    import flash.utils.*;
    import manager.*;
    import morn.core.components.*;
    import morn.core.handlers.*;
    import plugin.instances.*;
    import uiresource.instances.ui.*;
    import view.mornExtends.*;

    public class CZZRGame extends CZZRUI implements IInstance
    {
        private var totalExp:Number = 0;

        public function CZZRGame()
        {
            txt_fuck.isHtml = true;
            return;
        }// end function

        public function initShow(param1:Object, param2:Dictionary) : void
        {
            shuoming.toolTip = param1.tips.replace(/#""#/g, "\n");
            this.showItem(param1.show);
            ModelProxy.change("mainui", "changePao", true);
            return;
        }// end function

        private function showItem(param1:String) : void
        {
            var _loc_2:* = new ItemSplit();
            var _loc_3:* = _loc_2.doSplits(param1, "&", "/", "#");
            list.array = _loc_3[0];
            list.renderHandler = new Handler(this.itemRender, [list]);
            return;
        }// end function

        private function itemRender(param1:List, param2:Component, param3:int) : void
        {
            if (param3 < param1.length)
            {
                (param2 as FlashItem).data = param1.array[param3];
            }
            return;
        }// end function

        public function updateShow(param1:int, param2:Object) : void
        {
            switch(param1)
            {
                case InstancesPublic.TIMECHECKER:
                {
                    txt_time.text = TimeDataFormatUtil.getLeftTime(int(param2));
                    break;
                }
                case InstancesPublic.ADDEXP:
                {
                    this.totalExp = this.totalExp + int(param2);
                    txt_exp.text = this.totalExp + "";
                    WarningManager.show(18, ["经验", "+" + int(param2), this.totalExp]);
                    break;
                }
                case InstancesPublic.FUCKPOINT:
                {
                    if (param2.x == 22 && param2.y == 24 || param2.x == 24 && param2.y == 17 || param2.x == 14 && param2.y == 26 || param2.x == 18 && param2.y == 26 || param2.x == 24 && param2.y == 20 || param2.x == 27 && param2.y == 31 || param2.x == 28 && param2.y == 14 || param2.x == 11 && param2.y == 32)
                    {
                        txt_fuck.text = "所在区域：<font color=\'#52B730\'>4倍区</font>";
                        txt_expEachMin.text = "可得经验：<font color=\'#52B730\'>" + 240000 * (int(UserData.getUserData("level") / 10) - 5) + "/分钟</font>";
                    }
                    else if (param2.x + param2.y < 88)
                    {
                        txt_fuck.text = "所在区域：<font color=\'#52B730\'>1倍区</font>";
                        txt_expEachMin.text = "可得经验：<font color=\'#52B730\'>" + 60000 * (int(UserData.getUserData("level") / 10) - 5) + "/分钟</font>";
                    }
                    else
                    {
                        txt_fuck.text = "所在区域：<font color=\'#52B730\'>安全区</font>";
                        txt_expEachMin.text = "可得经验：<font color=\'#52B730\'>0/分钟</font>";
                    }
                    break;
                }
                default:
                {
                    break;
                }
            }
            return;
        }// end function

        public function destroyShow(param1:Dictionary) : void
        {
            return;
        }// end function

        public function initEvent() : void
        {
            btn_tuichu.clickHandler = new Handler(this.doTuichu);
            return;
        }// end function

        private function doTuichu() : void
        {
            ModelProxy.change("zone", "exitInstance", null);
            return;
        }// end function

        public function removeEvent() : void
        {
            btn_tuichu.clickHandler = null;
            return;
        }// end function

    }
}
